package handle.query;

import common.Constants.ServiceConstant;
import common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import service.QueryService;
import service.TokenService;
import service.VerifyService;

/**
 * Created by allen on 11/18/15.
 */
@Controller
@RequestMapping("ssms/query")
public class QueryCourseTeacherHandler {

    @Autowired
    private QueryService queryService ;

    @Autowired
    private VerifyService verifyService ;

    @Autowired
    private TokenService tokenService ;

    @RequestMapping(value = "/course/teacher", method = RequestMethod.POST)
    public @ResponseBody
    Result process(@RequestHeader String token, @RequestBody String courseName) {

        Result  result = verifyService.verify(token, ServiceConstant.ADMIN_LEVEL) ;

        if( result.isSucces() ){

            result = queryService.queryCourseTeacherList(ServiceConstant.ADMIN_LEVEL, courseName);
        }

        return result ;

    }
}
